package forceoffer;



/**
 *杈撳叆鏌愪簩鍙夋爲鐨勫墠搴忛亶鍘嗗拰涓簭閬嶅巻鐨勭粨鏋滐紝璇烽噸寤哄嚭璇ヤ簩鍙夋爲銆傚亣璁捐緭鍏ョ殑鍓嶅簭閬嶅巻鍜屼腑搴忛亶鍘�
 *鐨勭粨鏋滀腑閮戒笉鍚噸澶嶇殑鏁板瓧銆備緥濡傝緭鍏ュ墠搴忛亶鍘嗗簭鍒梴1,2,4,7,3,5,6,8}鍜屼腑搴忛亶鍘嗗簭鍒梴4,7,2,1,5,3,8,6}锛�
 *鍒欓噸寤轰簩鍙夋爲骞惰繑鍥炪��
 *
 */
public class GetTree {
    public static void main(String args[]) {
      int[] pre={1,2,4,7,3,5,6,8};
      int[] in={4,7,2,1,5,3,8,6};
      TreeNode root=reConstructBinaryTree(pre,in);
      priotyVisite(root);
    }

    public static  TreeNode reConstructBinaryTree(int [] pre,int [] in){
        int rootindex=getrootindex(in,pre[0]);
        int i=1;
        while (i<rootindex) {
            int next=getrootindex(in,i);
        }
      return null;
    }
    
    public static int getrootindex(int[] in,int root){
        for (int i=0; i<in.length ; i++ ) {
            if (in[i]==root) {
               return i;
            }
        }
        return -1;
    }

    public static void priotyVisite(TreeNode root){
      if(root!=null) {
        System.out.print(root.val);
        priotyVisite(root.left);
        priotyVisite(root.right);
      }
    }
}
class TreeNode{
  int val;
  TreeNode  left;
  TreeNode right;
  public TreeNode(int x){
    val=x;
  }

}
